package com.ruoyi.cms.service.impl;

import com.ruoyi.cms.domain.CategoryAccount;
import com.ruoyi.cms.mapper.CategoryAccountMapper;
import com.ruoyi.cms.service.ICategoryAccountService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 账号分类配置Service业务层处理
 *
 * @author lorry
 * @date 2020-11-30
 */
@Service
public class CategoryAccountServiceImpl implements ICategoryAccountService {
    @Autowired
    private CategoryAccountMapper categoryAccountMapper;

    /**
     * 查询账号分类配置
     *
     * @param id 账号分类配置ID
     * @return 账号分类配置
     */
    @Override
    public CategoryAccount selectCategoryAccountById(Long id) {
        return categoryAccountMapper.selectCategoryAccountById(id);
    }

    /**
     * 查询账号分类配置列表
     *
     * @param categoryAccount 账号分类配置
     * @return 账号分类配置
     */
    @Override
    public List<CategoryAccount> selectCategoryAccountList(CategoryAccount categoryAccount) {
        return categoryAccountMapper.selectCategoryAccountList(categoryAccount);
    }

    /**
     * 新增账号分类配置
     *
     * @param categoryAccount 账号分类配置
     * @return 结果
     */
    @Override
    public int insertCategoryAccount(CategoryAccount categoryAccount) {
        categoryAccount.setCreateTime(DateUtils.getNowDate());
        return categoryAccountMapper.insertCategoryAccount(categoryAccount);
    }

    /**
     * 修改账号分类配置
     *
     * @param categoryAccount 账号分类配置
     * @return 结果
     */
    @Override
    public int updateCategoryAccount(CategoryAccount categoryAccount) {
        categoryAccount.setUpdateTime(DateUtils.getNowDate());
        return categoryAccountMapper.updateCategoryAccount(categoryAccount);
    }

    /**
     * 删除账号分类配置对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCategoryAccountByIds(String ids) {
        return categoryAccountMapper.deleteCategoryAccountByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除账号分类配置信息
     *
     * @param id 账号分类配置ID
     * @return 结果
     */
    @Override
    public int deleteCategoryAccountById(Long id) {
        return categoryAccountMapper.deleteCategoryAccountById(id);
    }
}
